package com.PVZ.view.canvas;

import com.PVZ.view.GameFrame;
import lombok.Getter;
import lombok.Setter;

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;

/**
 * Created by @Author: kabuda on @Date: 2021/5/27 20:27
 */
@Getter
@Setter
public class ToolsCanvas extends JPanel {
    private Image image;
    private Graphics graphics;

    public ToolsCanvas() {
        this.setOpaque(false);
        this.setSize(GameFrame.WIDTH, GameFrame.HEIGHT);

        image= new BufferedImage(GameFrame.WIDTH, GameFrame.HEIGHT, BufferedImage.TYPE_4BYTE_ABGR_PRE);
        graphics = image.getGraphics();
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(image, 0, 0, this);
    }
}
